﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace RazorPagesMovie.Models
{
    public class Movie
    {
        public int ID { get; set; }
       
        //添加验证规则
        [StringLength(60,MinimumLength =3)]
        [Required]      //该特性指示属性必须具有一个值
        public string Title { get; set; }

        [Display(Name = "Release Date")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
        public DateTime ReleaseDate { get; set; }

        //添加验证规则
        //RegularExpression 该特性用于限制可输入的字符
        [RegularExpression(@"^[A-Z]+[a-zA-Z\s]*$")]
        [Required]
        [StringLength(30)]
        public string Genre { get; set; }

        //添加验证规则
        [Range(1, 100)]
        [DataType(DataType.Currency)]
        [Column(TypeName ="decimal(18,2)")]   //使Price能正确映射到数据库中
        public decimal Price { get; set; }

        //添加属性
        //添加验证规则
        [RegularExpression(@"^[A-Z]+[a-zA-Z0-9""'\s-]*$")]
        [Required]
        [StringLength(5)]
        public string Rating { get; set; }
    }
}
